﻿#region Imports
using System.Windows.Input;
#endregion

namespace AddressBox.Util
{
    internal static class SendKeys
    {
        /// <summary>
        /// Sends the specified key.
        /// </summary>
        /// <param name="key">Key to be sent</param>
        internal static void Send(Key key)
        {
            if (Keyboard.PrimaryDevice != null)
            {
                if (Keyboard.PrimaryDevice.ActiveSource != null)
                {
                    InputEventArgs inputEventArgs
                        = new KeyEventArgs(Keyboard.PrimaryDevice, Keyboard.PrimaryDevice.ActiveSource, 0, Key.Down) { RoutedEvent = Keyboard.KeyDownEvent };
                    InputManager.Current.ProcessInput(inputEventArgs);
                }
            }
        }
    }
}
